""autocmd InsertEnter * nested : set norelativenumber
""autocmd InsertLeave * nested : set relativenumber
let g:go_version_warning = 0
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set t_Co=256
""set clipboard+=unnamedplus
set textwidth=96
set wrap
set nu
set showmatch
set tabstop=2
set shiftwidth=2
set softtabstop=2
set autoindent
set backspace=indent,eol,start
set smartindent
au filetype c,cpp set cindent
""set indentexpr
set listchars=tab:>-,trail:-
set laststatus=2
set ruler
set relativenumber
set hidden
set vb t_vb=
au GuiEnter * set t_vb=
syntax on
filetype plugin indent on
set nowrap
set ttyfast "should make scrolling faster
set colorcolumn=100
set updatetime=100
set lines=30 columns=100
""mapping
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {<CR>}<ESC>O
inoremap } {}<left>
inoremap ' ''<left>
inoremap " ""<left>
""
" Compile function
noremap <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
  exec "w"
  if &filetype == 'c'
		exec "!gcc % -o test"
    exec "!test"
  elseif &filetype == 'cpp'
    exec "!g++ -std=c++11 -Wall % -o a"
		exec "!a"
  elseif &filetype == 'java'
    exec "!javac %"
    exec "!time java %<"
  elseif &filetype == 'sh'
    :!time bash %
  elseif &filetype == 'python'
    set splitbelow
    :sp
    :term python3 %
  elseif &filetype == 'html'
    silent! exec "!".g:mkdp_browser." % &"
  elseif &filetype == 'markdown'
    exec "InstantMarkdownPreview"
  elseif &filetype == 'tex'
    silent! exec "VimtexStop"
    silent! exec "VimtexCompile"
  elseif &filetype == 'dart'
    exec "CocCommand flutter.run -d ".g:flutter_default_device
    silent! exec "CocCommand flutter.dev.openDevLog"
  elseif &filetype == 'javascript'
    set splitbelow
    :sp
    :term export DEBUG="INFO,ERROR,WARNING"; node --trace-warnings .
  elseif &filetype == 'go'
    set splitbelow
    "":term go run %
		exec "!go run %"
  endif
endfunc
""
filetype plugin indent on
set nocompatible
filetype off
hi Normal ctermfg=252 ctermbg=none
set termguicolors " enable true colors support
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
hi NonText ctermfg=gray guifg=grey10


" ===
" === Terminal Behaviors
" ===
let g:neoterm_autoscroll = 1
tnoremap <C-N> <C-\><C-N>
tnoremap <C-O> <C-\><C-N><C-O>
let g:terminal_color_0  = '#000000'
let g:terminal_color_1  = '#FF5555'
let g:terminal_color_2  = '#50FA7B'
let g:terminal_color_3  = '#F1FA8C'
let g:terminal_color_4  = '#BD93F9'
let g:terminal_color_5  = '#FF79C6'
let g:terminal_color_6  = '#8BE9FD'
let g:terminal_color_7  = '#BFBFBF'
let g:terminal_color_8  = '#4D4D4D'
let g:terminal_color_9  = '#FF6E67'
let g:terminal_color_10 = '#5AF78E'
let g:terminal_color_11 = '#F4F99D'
let g:terminal_color_12 = '#CAA9FA'
let g:terminal_color_13 = '#FF92D0'
let g:terminal_color_14 = '#9AEDFE'

""
""vim-plug
""
call plug#begin()
Plug 'bpietravalle/vim-bolt'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'nathanaelkane/vim-indent-guides'

Plug 'luochen1990/rainbow'
let g:rainbow_active = 1

"Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
""Plug 'puremourning/vimspector'
Plug 'bpietravalle/vim-bolt'
Plug 'theniceboy/vim-deus'
Plug 'theniceboy/vim-snippets'
Plug 'Chiel92/vim-autoformat'
Plug 'vim-syntastic/syntastic'


" +-----------+
" |    IDE    |
" +-----------+

Plug 'preservim/nerdtree' , {'on': ['NERDTreeToggle', 'NERDTree', 'NERDTreeFromBookmark', 'NERDTreeFind']}
let NERDTreeHijackNetrw = 1
let g:NERDTreeWinPos = "left"
let NERDTreeShowHidden=0
let NERDTreeShowBookmarks=1
" let NERDTreeIgnore = ['\.pyc$', '__pycache__']
let NERDTreeIgnore = ['\.pyc$', '__pycache__', '\.vscode$', 'tags',
                     \'\.exe$', '\.EXE$', '\.obj$', '\.OBJ$', '\.jpg$',
                     \'\.JPG', '\.png$', '\.PNG$', 'desktop.ini']
let g:NERDTreeWinSize=30
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
nnoremap <leader>nt :NERDTreeToggle<cr>
nnoremap <leader>nb :NERDTreeFromBookmark<Space>
nnoremap <leader>nf :NERDTreeFind<cr>

" 只剩下NERDTree时关闭窗口
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") &&
    \b:NERDTree.isTabTree()) | q | endif

Plug 'tpope/vim-vinegar'
let NERDTreeHijackNetrw = 0
Plug 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeIndicatorMapCustom = {
    \ "Modified"  : "M",
    \ "Staged"    : "S",
    \ "Deleted"   : "D",
    \ "Untracked" : "!",
    \ "Renamed"   : "»",
    \ "Unmerged"  : "⎇ ",
    \ "Dirty"     : "✖",
    \ "Clean"     : "✔",
    \ 'Ignored'   : '~',
    \ "Unknown"   : "?"
    \ }
"let g:NERDTreeIndicatorMapCustom = {
"    \ "Modified"  : "✹",
"    \ "Staged"    : "✚",
"    \ "Untracked" : "✭",
"    \ "Renamed"   : "➜",
"    \ "Unmerged"  : "═",
"    \ "Deleted"   : "✖",
"    \ "Dirty"     : "✗",
"    \ "Clean"     : "✔︎",
"    \ "Ignored"   : "☒",
"    \ "Unknown"   : "?"
"    \ }
" 不显示 Ignored 状态(a heavy feature may cost much more time)
let g:NERDTreeShowIgnoredStatus = 1

" Tagbar,代替TagList
" 要用来编写C++程序，还需要安装(ctags还支持其他语言，详见 :h tagbar.txt)：
" universal-ctags/ctags
" enechaev/packcc
" 其他语言支持，见https://github.com/majutsushi/tagbar/wiki
Plug 'majutsushi/tagbar'
nnoremap <leader>tb :TagbarToggle<cr>
" 当 ctags 不在PATH指定的目录中时，需要自行指定 ctags 的路径
" let g:tagbar_ctags_bin = '...\ctags.exe'
" 跳转后自动关闭
let g:tagbar_autoclose = 0
let g:tagbar_autofocus = 0
let g:tagbar_left = 0
let g:tagbar_width = 40
let g:tagbar_zoomwidth = 0  " 只使用所需的最大列数
let g:tagbar_vertical = 0   " 指定垂直窗口中显示的行数，为0时使用水平窗口
let g:tagbar_sort = 0       " 1 to sort by name
let g:tagbar_case_insensitive = 0   " set to 1 to use case-insensitive comparision while sorting
let g:tagbar_compact = 1    " 隐藏顶部的帮助提示
let g:tagbar_indent = 2     " 缩进空格数
let g:tagbar_singleclick = 0
let g:tagbar_foldlevel = 99 " 展开的最大级数
let g:tagbar_iconchars = ['▸', '▾']
" 操作系统 encoding
" let g:tagbar_systemenc = 'cp936'
" Tagbar 状态栏显示内容
function! TagbarStatusFunc(current, sort, fname, flags, ...) abort
    let colour = a:current ? '%#StatusLine#' : '%#StatusLineNC#'
    let flagstr = join(flags, '')
    if flagstr != ''
        let flagstr = '[' . flagstr . '] '
    endif
    return colour . '[' . sort . '] ' . flagstr . fname
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
let g:tagbar_use_cache = 1  " 使用缓存文件来加速 ctags 的解析

highlight TagbarVisiblityPrivate guifg=Red ctermfg=Red
highlight TagbarVisiblityProtected guifg=Blue ctermfg=Blue
highlight TagbarVisiblityPublic guifg=Green ctermfg=Green

let g:tagbar_type_cpp = {
            \ 'ctagstype' : 'c++',
            \ 'kinds'     : [
                \ 'd:macros:1:0',
                \ 'p:prototypes:1:0',
                \ 'g:enums',
                \ 'e:enumerators:0:0',
                \ 't:typedefs:0:0',
                \ 'n:namespaces',
                \ 'c:classes',
                \ 's:structs',
                \ 'u:unions',
                \ 'f:functions',
                \ 'm:members:0:0',
                \ 'v:variables:0:0'
            \ ],
            \ 'sro'        : '::',
            \ 'kind2scope' : {
                \ 'g' : 'enum',
                \ 'n' : 'namespace',
                \ 'c' : 'class',
                \ 's' : 'struct',
                \ 'u' : 'union'
            \ },
            \ 'scope2kind' : {
                \ 'enum'      : 'g',
                \ 'namespace' : 'n',
                \ 'class'     : 'c',
                \ 'struct'    : 's',
                \ 'union'     : 'u'
            \ }
        \ }


Plug 'vim-airline/vim-airline'
nnoremap <C-Tab> :bn<cr>
nnoremap <C-S-Tab> :bp<cr>
set laststatus=2 "1为关闭底部状态栏 2为开启"
set t_Co=256     "终端开启256色支持"

if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif
"let g:airline_powerline_fonts = 1

" 显示buffers
let g:airline#extensions#tabline#enabled=1    "Smarter tab line: 显示窗口tab和buffers
let g:airline#extensions#tabline#left_sep = ''  "separater
let g:airline#extensions#tabline#left_alt_sep = ''  "separater
"let g:airline#extensions#tabline#left_alt_sep = ''  "separater
let g:airline#extensions#tabline#right_sep = ''  "separater
let g:airline#extensions#tabline#right_alt_sep = ''  "separater
"let g:airline#extensions#tabline#right_alt_sep = ''  "separater
let g:airline#extensions#tabline#formatter = 'default'  "formater

" NERDTree
let g:airline#extensions#nerdtree_status = 1

"let g:airline_left_sep = '»'
let g:airline_left_sep = ''
"let g:airline_left_alt_sep = ''  "separater
let g:airline_left_alt_sep = ''  "separater
"let g:airline_right_sep = '«'
let g:airline_right_sep = ''
"let g:airline_right_alt_sep = ''  "separater
let g:airline_right_alt_sep = ''  "separater
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '☰ '
"let g:airline_symbols.linenr = '␊'
"let g:airline_symbols.linenr = '␤'
"let g:airline_symbols.linenr = '¶'
let g:airline_symbols.maxlinenr = '㏑'
"let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.branch = '⎇'
"let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
"let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = 'Ɇ'
let g:airline_symbols.whitespace = 'Ξ'
call plug#end()
"===coc
let g:coc_global_extensions = [
 \ 'coc-diagnostic',
 \ 'coc-yank',
 \ 'coc-snippets']
set updatetime=100
""set shortmess+=c
set guifont=MesloLGS_NF:h13
color deus
"===
"===airline
"===
let airline_powerline_fonts = 1
"let g:airline#extensions#tabline#formatter = 'default'
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='bubblegum'


